<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>ICONIC Gallery</title>
        <link
            rel="icon"
            href="https://raw.githubusercontent.com/YuheshPandian/ICONIC/refs/heads/main/icons/light/iconic.svg"
            type="image/svg+xml"
        />
        <script
            src="https://kit.fontawesome.com/0f7ac66354.js"
            crossorigin="anonymous"
        ></script>
        <style>
            @import url("https://fonts.googleapis.com/css2?family=Inter&family=Montserrat&family=Poppins&display=swap");

            * {
                margin: 0;
                padding: 0;
                box-sizing: border-box;
            }

            body {
                font-family: system-ui, sans-serif;
                background: #092635;
                padding: 20px;
                color: #ddd;
            }

            nav {
                display: flex;
                align-items: center;
                justify-content: space-between;
                background: rgb(27, 66, 66);
                position: fixed;
                top: 0;
                left: 0;
                z-index: 100;
                width: 100%;
                padding: 12px 16px;
                min-height: 80px;
            }

            nav ul {
                display: flex;
                align-items: center;
                gap: 20px;
                list-style: none;
            }

            nav ul a {
                font-size: 1.35rem;
                color: #5c8374;
                text-decoration: none;
                transition: 0.3s ease;
            }

            nav ul a:hover {
                color: #9ec8b9;
            }

            main {
                margin: 100px auto;
            }

            h1 {
                text-align: center;
                font-size: 2.75rem;
                font-family: Inter, sans-serif;
                font-weight: 600;
                color: #5c8374;
                opacity: 0;
                animation: fadeInText 0.7s ease forwards;
                animation-delay: 0.7s;
            }

            h2 {
                font-family: Poppins, sans-serif;
                font-weight: 300;
                color: #9ec8b9;
                border-bottom: 2px solid #1b4242;
                margin-bottom: 20px;
                opacity: 0;
                animation: fadeInText 0.7s ease forwards;
                animation-delay: 0.7s;
            }

            .section {
                margin-top: 40px;
            }

            .icon-grid {
                display: flex;
                flex-wrap: wrap;
                gap: 16px;
                opacity: 0;
                animation: fadeInPage 0.8s ease forwards;
            }

            .icon-container {
                width: 100px;
                text-align: center;
            }

            .icon-container img {
                width: 64px;
                height: 64px;
                padding: 8px;
                border-radius: 50%;
                background: #1b4242;
                transition: 100ms ease-out;
            }

            .icon-container img:hover {
                background: #9ec8b9;
                box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
                width: 60px;
                height: 60px;
            }

            .label {
                font-size: 12px;
                margin: 6px 0;
                background: #1b4242;
                padding: 4px 2px;
                border-radius: 8px;
                cursor: pointer;
                font-family: Montserrat, sans-serif;
                font-weight: 600;
                max-width: 100px;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
            }

            .footer-links {
                margin-top: 30px;
                display: flex;
                align-items: center;
                justify-content: center;
            }

            .footer-links a {
                font-size: 2rem;
                color: #9ec8b9;
            }

            button.toggle-btn {
                margin: 30px auto;
                display: block;
                background-color: #1b4242;
                color: #9ec8b9;
                border: none;
                padding: 10px 20px;
                font-family: Inter, sans-serif;
                font-weight: 500;
                border-radius: 12px;
                cursor: pointer;
            }

            button.toggle-btn:hover {
                background-color: #5c8374;
                color: #fff;
            }

            @keyframes fadeInText {
                to {
                    opacity: 1;
                }
            }

            @keyframes fadeInPage {
                to {
                    opacity: 1;
                }
            }

            @media (max-width: 900px) {
                body {
                    font-size: 18px;
                    padding: 0;
                }

                main {
                    padding-inline: 1rem;
                }
                nav {
                    justify-content: center;
                    align-items: center;
                    ul li a {
                        font-size: 1.55rem;
                    }
                }
                nav .logo {
                    img {
                        width: 100px;
                    }
                    justify-self: flex-start;
                    position: absolute;
                    left: 10px;
                    top: 24px;
                }

                nav ul li:last-child {
                    position: absolute;
                    right: 10px;
                }

                h1 {
                    font-size: 2.25rem;
                }

                .icon-grid {
                    gap: 12px;
                }

                .icon-container {
                    width: 70px;
                }

                .icon-container img {
                    width: 48px;
                    height: 48px;
                }

                .icon-container img:hover {
                    width: 40px;
                    height: 40px;
                }
            }

            @media (max-width: 480px) {
                body {
                    background: #092635;
                    margin-inline: 0;
                    padding: 0;
                }

                nav ul li a {
                    font-size: 1.35rem;
                }
                nav .logo {
                    top: 16px;
                }
                nav .logo img {
                    content: url("https://raw.githubusercontent.com/YuheshPandian/ICONIC/refs/heads/main/icons/dark/iconic.svg");
                    width: 50px;
                }

                h1 {
                    font-size: 2.25rem;
                }

                .icon-grid {
                    gap: 8px;
                }

                .icon-container {
                    width: 60px;
                    position: relative;
                }

                .icon-container img {
                    width: 54px;
                    height: 54px;
                }

                .icon-container img:hover {
                    width: 54px;
                    height: 54px;
                }

                .icon-container .label {
                    display: none;
                }

                .icon-container:focus {
                    .label {
                        display: absolute;
                        z-index: 100;
                        opacity:65%;%
                    }
                }
                .copy-info-text {
                    display:none;
                }
            }
        </style>
    </head>
    <body>
        <header>
            <nav>
                <span class="logo"
                    ><img
                        src="https://raw.githubusercontent.com/YuheshPandian/ICONIC/refs/heads/main/assets/Banner.svg"
                        alt="Logo"
                        width="150px"
                /></span>
                <ul>
                    <li><a href="/">Home</a></li>
                    <li><a href="/gallery/">Gallery</a></li>
                    <li>
                        <a href="https://github.com/YuheshPandian/ICONIC"
                            ><i class="fa-brands fa-github"></i
                        ></a>
                    </li>
                </ul>
            </nav>
        </header>

        <main>
            <h1>Icon Gallery</h1>

            <button class="toggle-btn" onclick="toggleTheme()">
                Toggle Icon Theme
            </button>

            <p
                style="
                    color: #5c8374de;
                    font-family: poppins, sans-serif;
                    margin-block: 20px;
                "
                class="copy-info-text"
            >
                Click on label to copy HTML snippet
            </p>

            <div id="icon-section-dark" class="icon-grid">
                {% for icon in dark_icons %}
                <div class="icon-container">
                    <img src="/dark/{{ icon|cut:'.svg' }}" alt="{{ icon }}" />
                    <div class="label" onclick="copyLabelText(this,'dark')">
                        {{ icon|cut:'.svg' }}
                    </div>
                </div>
                {% endfor %}
            </div>

            <div
                id="icon-section-light"
                class="icon-grid"
                style="display: none"
            >
                {% for icon in light_icons %}
                <div class="icon-container">
                    <img
                        src="/light/{{ icon|cut:'.svg' }}"
                        alt="{{ icon }}"
                        style="background: #9ec8b9"
                    />
                    <div
                        class="label"
                        onclick="copyLabelText(this,'light')"
                        style="background: #9ec8b9; color: #092635"
                    >
                        {{ icon|cut:'.svg' }}
                    </div>
                </div>
                {% endfor %}
            </div>
        </main>

        <div class="footer-links">
            <a href="https://github.com/YuheshPandian/ICONIC"
                ><i class="fa-brands fa-github"></i
            ></a>
        </div>

        <script>
            function showPopup(message) {
                const popup = document.createElement("div");
                popup.textContent = message;

                Object.assign(popup.style, {
                    position: "fixed",
                    bottom: "40px",
                    left: "50%",
                    transform: "translateX(-50%)",
                    background: "#5c8374de",
                    color: "#fff",
                    padding: "10px 20px",
                    borderRadius: "10px",
                    fontFamily: "Inter, sans-serif",
                    fontSize: "1rem",
                    boxShadow: "0 4px 12px rgba(0, 0, 0, 0.25)",
                    opacity: "1",
                    transition: "opacity 0.4s ease",
                    zIndex: "9999",
                });

                document.body.appendChild(popup);

                setTimeout(() => {
                    popup.style.opacity = "0";
                }, 2000);
                setTimeout(() => {
                    popup.remove();
                }, 2500);
            }

            function copyLabelText(element, theme) {
                const text = element.textContent.trim();
                const content = `<img src="https://iconic-api.onrender.com/${theme}/${text}" width="64px" />`;

                if (!navigator.clipboard) {
                    showPopup("Clipboard not supported");
                    return;
                }

                navigator.clipboard
                    .writeText(content)
                    .then(() => {
                        showPopup(`Copied "${text}" to clipboard!`);
                    })
                    .catch((err) => {
                        console.error("Clipboard copy failed:", err);
                        showPopup("Failed to copy!");
                    });
            }

            let isDarkTheme = true;

            function toggleTheme() {
                const darkSection =
                    document.getElementById("icon-section-dark");
                const lightSection =
                    document.getElementById("icon-section-light");

                if (isDarkTheme) {
                    darkSection.style.display = "none";
                    lightSection.style.display = "flex";
                } else {
                    darkSection.style.display = "flex";
                    lightSection.style.display = "none";
                }

                isDarkTheme = !isDarkTheme;
            }
        </script>
    </body>
</html>
